﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ParkingLot.Entitys.Enums;
using ParkingLot.Entitys.Exceptions;

namespace ParkingLot.Utility.Factory
{
    /// <summary>
    /// 异常工厂
    /// </summary>
    public class ExceptionFactory
    {
        /// <summary>
        /// 创建异常
        /// </summary>
        /// <param name="exceptionType">异常类型</param>
        /// <param name="message">异常内容</param>
        /// <returns></returns>
        public static Exception CreateException(ExceptionType exceptionType,string message)
        {
            Exception exception = null;
            string exceptionMessage;
            switch (exceptionType)
            {
                case ExceptionType.DbsessionException:
                    exceptionMessage = $"数据库会话异常{message}";
                    exception =new DbsessionException(exceptionMessage);
                    break;
                case ExceptionType.BusinessException:
                    exceptionMessage = $"业务异常{message}";
                    exception=new BusinessException(exceptionMessage);
                    break;
            }
            return exception;
        }
    }
}
